//package com.gzu.shop.config;
//
//import com.gzu.shop.interceptor.JwtTokenUserInterceptor;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.CorsRegistry;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
//
///**
// * 配置类，注册web层相关组件
// */
//@Configuration
//@AllArgsConstructor
//@Slf4j
//public class WebMvcConfiguration extends WebMvcConfigurationSupport {
//    private JwtTokenUserInterceptor jwtTokenUserInterceptor;
//    /**
//     * 注册自定义拦截器
//     * @param registry
//     */
//    protected void addInterceptors(InterceptorRegistry registry) {
//        log.info("开始注册自定义拦截器...");
//        registry.addInterceptor(jwtTokenUserInterceptor)
//                .addPathPatterns("/**")
////                .excludePathPatterns("/user/register")
////                .excludePathPatterns("/admin/register")
//                .excludePathPatterns("/user/login")
////                .excludePathPatterns("/admin/login")
//                .excludePathPatterns("/v3/api-docs/**")
//                .excludePathPatterns("/swagger-ui/index.html/**")
//
//        ;
//        log.info("拦截器注册完成");
//
//    }
//
//    @Override
//    protected void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**")
//                .allowedOriginPatterns("*")
//                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
//                .allowedHeaders("*")
//                .allowCredentials(true)
//                .maxAge(3600);
//    }
//
//    /**
//     * 设置静态资源映射，主要是访问接口文档（html、js、css）
//     * @param registry
//     */
//
//    // http://localhost:8085/doc.html#/
//
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("doc.html")
//                .addResourceLocations("classpath:/META-INF/resources/");
//
//        registry.addResourceHandler("swagger-ui.html")
//                .addResourceLocations("classpath:/META-INF/resources/");
//
//        registry.addResourceHandler("/webjars/**")
//                .addResourceLocations("classpath:/META-INF/resources/webjars/");
//    }
//
//}
